package com.zkool.train.controller;

import com.zkool.train.service.TrainService;
import com.zkool.train.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by zhaokui on 2019/8/11.
 */
@RestController
@RequestMapping("/train")
public class TrainController {

    @Autowired
    private TrainService trainService;

    @GetMapping("/timetable/{code}")
    public R getTrainTimetable(@PathVariable("code") String code){
        if(code == null || "".equals(code.trim())){
            return R.error("请输入车次号");
        }
        return R.ok(trainService.getOrSaveTrainNumber(code.toUpperCase()));
    }


}
